package com.example.speeddating.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.speeddating.annotaion.LoginUser;
import com.example.speeddating.annotaion.TokenCheck;
import com.example.speeddating.common.BaseResponse;
import com.example.speeddating.common.RespGenerator;
import com.example.speeddating.entity.TaohuaDetail;
import com.example.speeddating.entity.TokenEntity;
import com.example.speeddating.service.TaohuaDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tina
 * @since 2023-06-28 11:14:34
 */
@RestController
@RequestMapping("/taohua")
public class TaohuaDetailController {

    @Autowired
    private TaohuaDetailService taohuaDetailService;

    @GetMapping("/list")
    @TokenCheck(roles = "user")
    public BaseResponse<Page> taohuaDetail(@LoginUser TokenEntity tokenEntity, @RequestParam(defaultValue = "1") int pageNum , @RequestParam(defaultValue = "10") int pageSize){
        QueryWrapper<TaohuaDetail> queryWrapper = new QueryWrapper<>();
        return RespGenerator.returnOK(taohuaDetailService.getTaohuaDetail(new Page<>(pageNum,pageSize),tokenEntity.getId()));
    }

    @GetMapping("/num")
    @TokenCheck(roles = "user")
    public BaseResponse<Integer> taohuaNum(@LoginUser TokenEntity tokenEntity){
        return RespGenerator.returnOK(taohuaDetailService.selectTaohuaSum(tokenEntity.getId()));
    }

}
